// pages/profile/questionnaire/questionnaire.js
const app = getApp()
var store = require("../../../utils/storageUtil.js")
const constant = require("../../../constant.js")
const storage = require("../../../utils/storage.js")

import WxValidate from '../../../utils/WxValidate'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    rateCount: 11,
    rateValue: 3,
    textareaShow: true,
    qiniu: constant.resource.qiniu,
    siteAnswerThreeReasons: [{
        value: '器械不规整',
        name: '器械不规整'
      },
      {
        value: '器械生锈',
        name: '器械生锈'
      },
      {
        value: '瑜伽垫有汗渍',
        name: '瑜伽垫有汗渍'
      },
      {
        value: '门店空气流通不畅',
        name: '门店空气流通不畅'
      },
      {
        value: '门店温度过低',
        name: '门店温度过低'
      },
      {
        value: '门店温度过高',
        name: '门店温度过高'
      },
    ],
    serverAnswerOneReasons: [{
        value: '工作人员无微笑',
        name: '工作人员无微笑'
      },
      {
        value: '没有主动提供服务',
        name: '没有主动提供服务'
      },
      {
        value: '答疑不清晰',
        name: '答疑不清晰'
      },
    ],
    serverAnswerThreeReasons: [{
        value: '精神状态不佳',
        name: '精神状态不佳'
      },
      {
        value: '未穿工服',
        name: '未穿工服'
      },
      {
        value: '头发油腻',
        name: '头发油腻'
      }, {
        value: '有异味',
        name: '有异味'
      },
    ],
    serverAnswerFourReasons: [{
        value: '未辅助指导',
        name: '未辅助指导'
      },
      {
        value: '沟通不热情',
        name: '沟通不热情'
      },
      {
        value: '上课玩手机',
        name: '上课玩手机'
      },
    ],
    coachAnswerOneReasons: [{
        value: '未主动询问',
        name: '未主动询问'
      },
      {
        value: '未制定清晰的数字目标',
        name: '未制定清晰的数字目标'
      }
    ],

    coachAnswerTwoReasons: [{
      value: '未根据目标调整',
      name: '未根据目标调整'
    }],
    coachAnswerThreeReasons: [{
        value: '无线上服务',
        name: '无线上服务'
      },
      {
        value: '无问候',
        name: '无问候'
      },
      {
        value: '未指导',
        name: '未指导'
      }, {
        value: '未提出建议',
        name: '未提出建议'
      }
    ],
    coachAnswerSixReasons: [{
        value: '从未收到过',
        name: '从未收到过'
      },
      {
        value: '并未主动关心完成情况',
        name: '并未主动关心完成情况'
      },
      {
        value: '未提出建议',
        name: '未提出建议'
      }
    ],
    coachAnswerFiveReasons: [{
        value: '未制定目标',
        name: '未制定目标'
      },
      {
        value: '未提供线上服务',
        name: '未提供线上服务'
      },
      {
        value: '未定期测量数据',
        name: '未定期测量数据'
      },
      {
        value: '未定期拍摄对比照',
        name: '未定期拍摄对比照'
      }
    ],
    coachAnswerEightReasons: [{
        value: '不熟悉其他教练',
        name: '不熟悉其他教练'
      },
      {
        value: '对现在的教练很满意',
        name: '对现在的教练很满意'
      }
    ],
    coachChangeReasons: [{
        value: '主教练上课太随意',
        name: '主教练上课太随意'
      },
      {
        value: '预约不上课程',
        name: '预约不上课程'
      },
      {
        value: '主教练不专业',
        name: '主教练不专业'
      },
      {
        value: '主教练态度不好',
        name: '主教练态度不好'
      },
      {
        value: '课程太难动作跟不上',
        name: '课程太难动作跟不上'
      },
      {
        value: '主教练上课迟到',
        name: '主教练上课迟到'
      },
      {
        value: '主教练没提供周期式服务',
        name: '主教练没提供周期式服务'
      },
      {
        value: '其他',
        name: '其他'
      }
    ],
    totalAnswerOneReasons: [{
      value: '私密性',
      name: '私密性'
    },
  ],totalAnswerTwoReasons: [{
    value: '无大众点评APP',
    name: '无大众点评APP'
  },{
    value: '不知道怎么写',
    name: '不知道怎么写'
  },{
    value: '不愿意写',
    name: '不愿意写'
  },
],
    totalRateReasons: [{
        value: '门店环境',
        name: '门店环境'
      },
      {
        value: '门店服务',
        name: '门店服务'
      },
      {
        value: '门店器械',
        name: '门店器械'
      },
      {
        value: '课程/教练',
        name: '课程/教练'
      },
      {
        value: '课程价格过高',
        name: '课程价格过高'
      }
    ],
    totalRateReasonsTwo: [{
      value: '达成周期目标',
      name: '达成周期目标'
    },
    {
      value: '教练技术',
      name: '教练技术'
    },
    {
      value: '谈吐专业',
      name: '谈吐专业'
    },
    {
      value: '授课专业',
      name: '授课专业'
    },
    {
      value: '团队服务热情',
      name: '团队服务热情'
    },
    {
      value: '离家近',
      name: '离家近'
    },
    {
      value: '环境私密',
      name: '环境私密'
    }
  ],totalAnswerNine1Reasons: [
    {
      value: '人马君特色课',
      name: '人马君特色课'
    },
    {
      value: '人马君企业定制课程',
      name: '人马君企业定制课程'
    },
    {
      value: '轻食系列',
      name: '轻食系列'
    },
    {
      value: 'FMA管理培训课程',
      name: 'FMA管理培训课程'
    }
  ],
  totalAnswerNine2Reasons: [
    {
      value: '不清楚',
      name: '不清楚'
    },
    {
      value: '未体验',
      name: '未体验'
    }
  ],totalAnswerNine3Reasons: [
    {
      value: '人马君特色课',
      name: '人马君特色课'
    },
    {
      value: '人马君企业定制课程',
      name: '人马君企业定制课程'
    },
    {
      value: '轻食系列',
      name: '轻食系列'
    },
    {
      value: 'FMA管理培训课程',
      name: 'FMA管理培训课程'
    }
  ],
    siteAnswerTwoReasons: [{
        value: '浴室物资不足',
        name: '浴室物资不足'
      },
      {
        value: '衣柜异味',
        name: '衣柜异味'
      },
      {
        value: '下水道异味',
        name: '下水道异味'
      },
      {
        value: '水温不适宜',
        name: '水温不适宜'
      },
      {
        value: '台面不整洁',
        name: '台面不整洁'
      },
      {
        value: '拖鞋摆放不整齐',
        name: '拖鞋摆放不整齐'
      },
      {
        value: '垃圾桶过满',
        name: '垃圾桶过满'
      },
      {
        value: '室内温度偏冷',
        name: '室内温度偏冷'
      },
      {
        value: '室内温度偏热',
        name: '室内温度偏热'
      }
    ],

    siteAnswerTwoReasonsNew: [{
        value: '更衣柜异味',
        name: '更衣柜异味'
      },
      {
        value: '拖鞋摆放不整齐',
        name: '拖鞋摆放不整齐'
      },
      {
        value: '垃圾桶过满',
        name: '垃圾桶过满'
      },
      {
        value: '室内温度偏冷',
        name: '室内温度偏冷'
      },
      {
        value: '室内温度偏热',
        name: '室内温度偏热'
      }
    ],
    citys: ['上海市', '杭州市'],
    areas: [{
        name: '上海市',
        area: ['宝山区', '崇明区', '奉贤区', '虹口区', '黄浦区', '嘉定区', '静安区', '金山区', '卢湾区', '闵行区', '南汇区', '浦东区', '普陀区', '青浦区', '松江区', '徐汇区', '杨浦区', '闸北区', '长宁区']
      },
      {
        name: '杭州市',
        area: ['上城区', '下城区', '江干区', '拱墅区', '西湖区', '滨江区', '萧山区', '余杭区', '富阳区']
      }
    ],
    disabled: false
  },

  siteAnswerThreeReasonsChange: function (e) {
    var siteAnswerThreeReasons = this.data.siteAnswerThreeReasons;
    var checkArr = e.detail.value;
    var siteAnswerThreeReason = '';
    for (var i = 0; i < siteAnswerThreeReasons.length; i++) {
      if (checkArr.indexOf(siteAnswerThreeReasons[i].value) != -1) {
        siteAnswerThreeReasons[i].checked = true;
        siteAnswerThreeReason = siteAnswerThreeReason + siteAnswerThreeReasons[i].value + ";"
      } else {
        siteAnswerThreeReasons[i].checked = false;
      }
    }

    this.setData({
      siteAnswerThreeReasons: siteAnswerThreeReasons,
      siteAnswerThreeReason: siteAnswerThreeReason
    })
  },

  serverAnswerOneReasonsChange: function (e) {
    var serverAnswerOneReasons = this.data.serverAnswerOneReasons;
    var checkArr = e.detail.value;
    var serverAnswerOneReason = '';
    for (var i = 0; i < serverAnswerOneReasons.length; i++) {
      if (checkArr.indexOf(serverAnswerOneReasons[i].value) != -1) {
        serverAnswerOneReasons[i].checked = true;
        serverAnswerOneReason = serverAnswerOneReason + serverAnswerOneReasons[i].value + ";"
      } else {
        serverAnswerOneReasons[i].checked = false;
      }
    }

    this.setData({
      serverAnswerOneReasons: serverAnswerOneReasons,
      serverAnswerOneReason: serverAnswerOneReason
    })
  },

  serverAnswerThreeReasonsChange: function (e) {
    var serverAnswerThreeReasons = this.data.serverAnswerThreeReasons;
    var checkArr = e.detail.value;
    var serverAnswerThreeReason = '';
    for (var i = 0; i < serverAnswerThreeReasons.length; i++) {
      if (checkArr.indexOf(serverAnswerThreeReasons[i].value) != -1) {
        serverAnswerThreeReasons[i].checked = true;
        serverAnswerThreeReason = serverAnswerThreeReason + serverAnswerThreeReasons[i].value + ";"
      } else {
        serverAnswerThreeReasons[i].checked = false;
      }
    }

    this.setData({
      serverAnswerThreeReasons: serverAnswerThreeReasons,
      serverAnswerThreeReason: serverAnswerThreeReason
    })
  },

  serverAnswerFourReasonsChange: function (e) {
    var serverAnswerFourReasons = this.data.serverAnswerFourReasons;
    var checkArr = e.detail.value;
    var serverAnswerFourReason = '';
    for (var i = 0; i < serverAnswerFourReasons.length; i++) {
      if (checkArr.indexOf(serverAnswerFourReasons[i].value) != -1) {
        serverAnswerFourReasons[i].checked = true;
        serverAnswerFourReason = serverAnswerFourReason + serverAnswerFourReasons[i].value + ";"
      } else {
        serverAnswerFourReasons[i].checked = false;
      }
    }

    this.setData({
      serverAnswerFourReasons: serverAnswerFourReasons,
      serverAnswerFourReason: serverAnswerFourReason
    })
  },

  coachAnswerOneReasonsChange: function (e) {
    var coachAnswerOneReasons = this.data.coachAnswerOneReasons;
    var checkArr = e.detail.value;
    var coachAnswerOneReason = '';
    for (var i = 0; i < coachAnswerOneReasons.length; i++) {
      if (checkArr.indexOf(coachAnswerOneReasons[i].value) != -1) {
        coachAnswerOneReasons[i].checked = true;
        coachAnswerOneReason = coachAnswerOneReason + coachAnswerOneReasons[i].value + ";"
      } else {
        coachAnswerOneReasons[i].checked = false;
      }
    }

    this.setData({
      coachAnswerOneReasons: coachAnswerOneReasons,
      coachAnswerOneReason: coachAnswerOneReason
    })
  },


  coachAnswerTwoReasonsChange: function (e) {
    var coachAnswerTwoReasons = this.data.coachAnswerTwoReasons;
    var checkArr = e.detail.value;
    var coachAnswerTwoReason = '';
    for (var i = 0; i < coachAnswerTwoReasons.length; i++) {
      if (checkArr.indexOf(coachAnswerTwoReasons[i].value) != -1) {
        coachAnswerTwoReasons[i].checked = true;
        coachAnswerTwoReason = coachAnswerTwoReason + coachAnswerTwoReasons[i].value + ";"
      } else {
        coachAnswerTwoReasons[i].checked = false;
      }
    }

    this.setData({
      coachAnswerTwoReasons: coachAnswerTwoReasons,
      coachAnswerTwoReason: coachAnswerTwoReason
    })
  },


  coachAnswerThreeReasonsChange: function (e) {
    var coachAnswerThreeReasons = this.data.coachAnswerThreeReasons;
    var checkArr = e.detail.value;
    var coachAnswerThreeReason = '';
    for (var i = 0; i < coachAnswerThreeReasons.length; i++) {
      if (checkArr.indexOf(coachAnswerThreeReasons[i].value) != -1) {
        coachAnswerThreeReasons[i].checked = true;
        coachAnswerThreeReason = coachAnswerThreeReason + coachAnswerThreeReasons[i].value + ";"
      } else {
        coachAnswerThreeReasons[i].checked = false;
      }
    }

    this.setData({
      coachAnswerThreeReasons: coachAnswerThreeReasons,
      coachAnswerThreeReason: coachAnswerThreeReason
    })
  },


  coachAnswerSixReasonsChange: function (e) {
    var coachAnswerSixReasons = this.data.coachAnswerSixReasons;
    var checkArr = e.detail.value;
    var coachAnswerSixReason = '';
    for (var i = 0; i < coachAnswerSixReasons.length; i++) {
      if (checkArr.indexOf(coachAnswerSixReasons[i].value) != -1) {
        coachAnswerSixReasons[i].checked = true;
        coachAnswerSixReason = coachAnswerSixReason + coachAnswerSixReasons[i].value + ";"
      } else {
        coachAnswerSixReasons[i].checked = false;
      }
    }

    this.setData({
      coachAnswerSixReasons: coachAnswerSixReasons,
      coachAnswerSixReason: coachAnswerSixReason
    })
  },


  coachAnswerFiveReasonsChange: function (e) {
    var coachAnswerFiveReasons = this.data.coachAnswerFiveReasons;
    var checkArr = e.detail.value;
    var coachAnswerFiveReason = '';
    for (var i = 0; i < coachAnswerFiveReasons.length; i++) {
      if (checkArr.indexOf(coachAnswerFiveReasons[i].value) != -1) {
        coachAnswerFiveReasons[i].checked = true;
        coachAnswerFiveReason = coachAnswerFiveReason + coachAnswerFiveReasons[i].value + ";"
      } else {
        coachAnswerFiveReasons[i].checked = false;
      }
    }

    this.setData({
      coachAnswerFiveReasons: coachAnswerFiveReasons,
      coachAnswerFiveReason: coachAnswerFiveReason
    })
  },

  coachAnswerEightReasonsChange: function (e) {
    var coachAnswerEightReasons = this.data.coachAnswerEightReasons;
    var checkArr = e.detail.value;
    var coachAnswerEightReason = '';
    for (var i = 0; i < coachAnswerEightReasons.length; i++) {
      if (checkArr.indexOf(coachAnswerEightReasons[i].value) != -1) {
        coachAnswerEightReasons[i].checked = true;
        coachAnswerEightReason = coachAnswerEightReason + coachAnswerEightReasons[i].value + ";"
      } else {
        coachAnswerEightReasons[i].checked = false;
      }
    }

    this.setData({
      coachAnswerEightReasons: coachAnswerEightReasons,
      coachAnswerEightReason: coachAnswerEightReason
    })
  },

  totalAnswerOneReasonsChange: function (e) {
    var totalAnswerOneReasons = this.data.totalAnswerOneReasons;
    var checkArr = e.detail.value;
    var totalAnswerOneReason = '';
    for (var i = 0; i < totalAnswerOneReasons.length; i++) {
      if (checkArr.indexOf(totalAnswerOneReasons[i].value) != -1) {
        totalAnswerOneReasons[i].checked = true;
        totalAnswerOneReason = totalAnswerOneReason + totalAnswerOneReasons[i].value + ";"
      } else {
        totalAnswerOneReasons[i].checked = false;
      }
    }

    this.setData({
      totalAnswerOneReasons: totalAnswerOneReasons,
      totalAnswerOneReason: totalAnswerOneReason
    })
  },


  totalAnswerTwoReasonsChange: function (e) {
    var totalAnswerTwoReasons = this.data.totalAnswerTwoReasons;
    var checkArr = e.detail.value;
    var totalAnswerTwoReason = '';
    for (var i = 0; i < totalAnswerTwoReasons.length; i++) {
      if (checkArr.indexOf(totalAnswerTwoReasons[i].value) != -1) {
        totalAnswerTwoReasons[i].checked = true;
        totalAnswerTwoReason = totalAnswerTwoReason + totalAnswerTwoReasons[i].value + ";"
      } else {
        totalAnswerTwoReasons[i].checked = false;
      }
    }

    this.setData({
      totalAnswerTwoReasons: totalAnswerTwoReasons,
      totalAnswerTwoReason: totalAnswerTwoReason
    })
  },

  totalRateReasonsTwoChange: function (e) {
    var totalRateReasonsTwo = this.data.totalRateReasonsTwo;
    var checkArr = e.detail.value;
    var totalRateReasonTwo = '';
    for (var i = 0; i < totalRateReasonsTwo.length; i++) {
      if (checkArr.indexOf(totalRateReasonsTwo[i].value) != -1) {
        totalRateReasonsTwo[i].checked = true;
        totalRateReasonTwo = totalRateReasonTwo + totalRateReasonsTwo[i].value + ";"
      } else {
        totalRateReasonsTwo[i].checked = false;
      }
    }

    this.setData({
      totalRateReasonsTwo: totalRateReasonsTwo,
      totalRateReasonTwo: totalRateReasonTwo
    })
  },

  totalAnswerNine1ReasonsChange: function (e) {
    var totalAnswerNine1Reasons = this.data.totalAnswerNine1Reasons;
    var checkArr = e.detail.value;
    var totalAnswerNine1Reason = '';
    for (var i = 0; i < totalAnswerNine1Reasons.length; i++) {
      if (checkArr.indexOf(totalAnswerNine1Reasons[i].value) != -1) {
        totalAnswerNine1Reasons[i].checked = true;
        totalAnswerNine1Reason = totalAnswerNine1Reason + totalAnswerNine1Reasons[i].value + ";"
      } else {
        totalAnswerNine1Reasons[i].checked = false;
      }
    }

    this.setData({
      totalAnswerNine1Reasons: totalAnswerNine1Reasons,
      totalAnswerNine1Reason: totalAnswerNine1Reason
    })
  },


  totalAnswerNine2ReasonsChange: function (e) {
    var totalAnswerNine2Reasons = this.data.totalAnswerNine2Reasons;
    var checkArr = e.detail.value;
    var totalAnswerNine2Reason = '';
    for (var i = 0; i < totalAnswerNine2Reasons.length; i++) {
      if (checkArr.indexOf(totalAnswerNine2Reasons[i].value) != -1) {
        totalAnswerNine2Reasons[i].checked = true;
        totalAnswerNine2Reason = totalAnswerNine2Reason + totalAnswerNine2Reasons[i].value + ";"
      } else {
        totalAnswerNine2Reasons[i].checked = false;
      }
    }

    this.setData({
      totalAnswerNine2Reasons: totalAnswerNine2Reasons,
      totalAnswerNine2Reason: totalAnswerNine2Reason
    })
  },

  totalAnswerNine3ReasonsChange: function (e) {
    var totalAnswerNine3Reasons = this.data.totalAnswerNine3Reasons;
    var checkArr = e.detail.value;
    var totalAnswerNine3Reason = '';
    for (var i = 0; i < totalAnswerNine3Reasons.length; i++) {
      if (checkArr.indexOf(totalAnswerNine3Reasons[i].value) != -1) {
        totalAnswerNine3Reasons[i].checked = true;
        totalAnswerNine3Reason = totalAnswerNine3Reason + totalAnswerNine3Reasons[i].value + ";"
      } else {
        totalAnswerNine3Reasons[i].checked = false;
      }
    }

    this.setData({
      totalAnswerNine3Reasons: totalAnswerNine3Reasons,
      totalAnswerNine3Reason: totalAnswerNine3Reason
    })
  },

  serverAnswerThreeReasonInput: function (e) {
    this.setData({
      serverAnswerThreeReasonInput: e.detail.value
    })
  },

  serverAnswerFourReasonInput: function (e) {
    this.setData({
      serverAnswerFourReasonInput: e.detail.value
    })
  },

  serverAnswerOneReasonInput: function (e) {
    this.setData({
      serverAnswerOneReasonInput: e.detail.value
    })
  },

  customerSiteAnswerThreeReasonsInput: function (e) {
    this.setData({
      siteAnswerThreeReasonInput: e.detail.value
    })
  },

  customerSiteAnswerTwoReasonsInput: function (e) {
    this.setData({
      siteAnswerTwoReasonInput: e.detail.value
    })
  },

  customerSiteAnswerTwoReasonsNewInput: function (e) {
    this.setData({
      siteAnswerTwoReasonNewInput: e.detail.value
    })
  },

  coachAnswerOneReasonInput: function (e) {
    this.setData({
      coachAnswerOneReasonInput: e.detail.value
    })
  },

  coachAnswerTwoReasonInput: function (e) {
    this.setData({
      coachAnswerTwoReasonInput: e.detail.value
    })
  },

  coachAnswerThreeReasonInput: function (e) {
    this.setData({
      coachAnswerThreeReasonInput: e.detail.value
    })
  },

  coachAnswerSixReasonInput: function (e) {
    this.setData({
      coachAnswerSixReasonInput: e.detail.value
    })
  },

  coachAnswerFiveReasonInput: function (e) {
    this.setData({
      coachAnswerFiveReasonInput: e.detail.value
    })
  },

  coachAnswerEightReasonInput: function (e) {
    this.setData({
      coachAnswerEightReasonInput: e.detail.value
    })
  },

  totalAnswerOneReasonInput: function (e) {
    this.setData({
      totalAnswerOneReasonInput: e.detail.value
    })
  },
  totalAnswerTwoReasonInput: function (e) {
    this.setData({
      totalAnswerTwoReasonInput: e.detail.value
    })
  },
  totalRateReasonsTwoInput: function (e) {
    this.setData({
      totalRateReasonsTwoInput: e.detail.value
    })
  },
  totalAnswerNine3ReasonInput: function (e) {
    this.setData({
      totalAnswerNine3ReasonInput: e.detail.value
    })
  },

  coachChangeBinder: function (e) {

    console.log(e)

    var coachChangeReasons = this.data.coachChangeReasons;
    var checkArr = e.detail.value;
    var coachChangeReason = '';
    for (var i = 0; i < coachChangeReasons.length; i++) {
      if (checkArr.indexOf(coachChangeReasons[i].value) != -1) {
        coachChangeReasons[i].checked = true;
        coachChangeReason = coachChangeReason + coachChangeReasons[i].value + ";"
      } else {
        coachChangeReasons[i].checked = false;
      }
    }
    debugger
    this.setData({
      coachChangeReasons: coachChangeReasons,
      coachChangeReason: coachChangeReason
    })
  },

  totalRateReasonsChange: function (e) {
    var totalRateReasons = this.data.totalRateReasons;
    var checkArr = e.detail.value;
    var totalRateReason = '';
    for (var i = 0; i < totalRateReasons.length; i++) {
      if (checkArr.indexOf(totalRateReasons[i].value) != -1) {
        totalRateReasons[i].checked = true;
        totalRateReason = totalRateReason + totalRateReasons[i].value + ";";
      } else {
        totalRateReasons[i].checked = false;
      }
    }

    this.setData({
      totalRateReasons: totalRateReasons,
      totalRateReason: totalRateReason
    })
  },

  siteAnswerTwoReasonsChange: function (e) {

    console.log(e)

    var siteAnswerTwoReasons = this.data.siteAnswerTwoReasons;
    var checkArr = e.detail.value;
    var siteAnswerTwoReason = '';
    for (var i = 0; i < siteAnswerTwoReasons.length; i++) {
      if (checkArr.indexOf(siteAnswerTwoReasons[i].value) != -1) {
        siteAnswerTwoReasons[i].checked = true;
        siteAnswerTwoReason = siteAnswerTwoReason + siteAnswerTwoReasons[i].value + ";";
      } else {
        siteAnswerTwoReasons[i].checked = false;
      }
    }

    this.setData({
      siteAnswerTwoReasons: siteAnswerTwoReasons,
      siteAnswerTwoReason: siteAnswerTwoReason
    })
  },

  siteAnswerTwoReasonsNewChange: function (e) {

    console.log(e)

    var siteAnswerTwoReasonsNew = this.data.siteAnswerTwoReasonsNew;
    var checkArr = e.detail.value;
    var siteAnswerTwoReasonNew = '';
    for (var i = 0; i < siteAnswerTwoReasonsNew.length; i++) {
      if (checkArr.indexOf(siteAnswerTwoReasonsNew[i].value) != -1) {
        siteAnswerTwoReasonsNew[i].checked = true;
        siteAnswerTwoReasonNew = siteAnswerTwoReasonNew + siteAnswerTwoReasonsNew[i].value + ";";
      } else {
        siteAnswerTwoReasonsNew[i].checked = false;
      }
    }

    this.setData({
      siteAnswerTwoReasonsNew: siteAnswerTwoReasonsNew,
      siteAnswerTwoReasonNew: siteAnswerTwoReasonNew
    })
  },

  handleRadioChange: function (e) {
    console.log('radio发生change事件，携带value值为：', e.detail)
  },

  handleSiteChange: function (e) {
    this.setData({
      siteGrade: e.detail.value
    })
  },

  handleCoachChange: function (e) {
    this.setData({
      coachGrade: e.detail.value
    })
  },

  handleTotalChange: function (e) {
    var totalRateReasons = this.data.totalRateReasons;
    if (e.detail.value > 6) {
      for (var i = 0; i < totalRateReasons.length; i++) {
        totalRateReasons[i].checked = false;
      }
      this.setData({
        totalRateReason: '',
        totalRateReasons: totalRateReasons
      })

    }

    this.setData({
      totalGrade: e.detail.value
    })
  },

  handleCourseChange: function (e) {
    this.setData({
      courseGrade: e.detail.value
    })
  },

  bindPickerChange: function (e) {
    this.setData({
      cityIndex: e.detail.value,
      areaIndex: 0
    })
  },

  bindPickerAreaChange: function (e) {
    this.setData({
      areaIndex: e.detail.value
    })
  },

  formSubmit: function (e) {
    var that = this;

    var data = e.detail.value;

    if (!this.WxValidate.checkForm(data)) {

      // const error = this.WxValidate.errorList[0]
      wx.showModal({
        content: "请填写完整信息",
        showCancel: false,
      })
      return false
    } else {
      that.setData({
        disabled: true
      })
      wx.request({
        url: that.data.host + '/satisfaction-survey?unionid=' + that.data.unionid,
        method: 'POST',
        data: data,
        header: {
          'content-type': 'application/json'
        },
        success: function (res) {
          if (res.data.code == "0") {
            that.setData({
              textareaShow: !that.data.textareaShow,
              showModal: !that.data.showModal
            })
          } else {
            wx.showToast({
              title: res.data.message,
              icon: 'none',
              duration: 1000,
              mask: true
            });
            that.setData({
              disabled: false
            })
          }
        },
        fail: function (res) {
          wx.showToast({
            title: '提交问卷失败',
            icon: 'none',
            duration: 1000,
            mask: true
          })
          that.setData({
            disabled: false
          })
        }
      });
    }
  },

  oneAnswerChange: function (e) {
    this.setData({
      oneAnswerVal: e.detail.value
    })
  },

  threeAnswerChange: function (e) {
    this.setData({
      threeAnswerVal: e.detail.value
    })
  },

  fourAnswerChange: function (e) {
    this.setData({
      fourAnswerVal: e.detail.value
    })
  },

  siteAnswerThreeChange: function (e) {
    this.setData({
      site_answer_three: e.detail.value
    })
  },


  siteAnswerTwoChange: function (e) {
    this.setData({
      site_answer_two: e.detail.value
    })
  },

  coachOneAnswerChange: function(e) {
    this.setData({
      coach_answer_one: e.detail.value
    })
  },

  coachTwoAnswerChange: function(e) {
    this.setData({
      coach_answer_two: e.detail.value
    })
  },


  coachThreeAnswerChange: function(e) {
    this.setData({
      coach_answer_three: e.detail.value
    })
  },


  coachSixAnswerChange: function(e) {
    this.setData({
      coach_answer_six: e.detail.value
    })
  },

  coachFiveAnswerChange: function(e) {
    this.setData({
      coachAnswerFiveVal: e.detail.value
    })
  },

  coachAnswerEightChange: function(e) {
    this.setData({
      coach_answer_eight: e.detail.value
    })
  },

  totalAnswerOneChange: function(e) {
    this.setData({
      total_answer_one: e.detail.value
    })
  },

  totalAnswerTwoChange: function(e) {
    this.setData({
      total_answer_two: e.detail.value
    })
  },

  totalAnswerNineChange: function(e) {
    this.setData({
      total_answer_nine: e.detail.value
    })
  },

  bindTextareaVal: function (e) {
    let textareaName = e.currentTarget.dataset.textarea;
    let textareaVal = e.detail.value
    this.setData({
      [textareaName]: textareaVal
    })
  },

  coachAnswerEight: function (e) {
    this.setData({
      coach_answer_eight: e.detail.value
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      qiniu: constant.resource.qiniu,
      host: constant.api(app.globalData.pord).url,
      unionid: wx.getStorageSync(storage.keys.unionid)
    })

    this.initValidate();
  },

  initValidate: function () {
    // 验证字段的规则
    const rules = {
      city: {
        required: true,
      },
      district: {
        required: true,
      },
      server_answer_five: {
        required: true,
      },
      total_answer_three: {
        required: true,
      },
      site_answer_three: {
        required: true,
      },
      site_answer_two: {
        required: true,
      },
      server_answer_one: {
        required: true,
      },
      server_answer_three: {
        required: true,
      },
      coach_answer_one: {
        required: true,
      },
      coach_answer_two: {
        required: true,
      },
      coach_answer_three: {
        required: true,
      },
      coach_answer_five: {
        required: true,
      },
      coach_answer_six: {
        required: true,
      },
      coach_answer_eight: {
        required: true,
      },
      coach_services: {
        required: true,
      },
      total_answer_one: {
        required: true,
      },
      total_answer_two: {
        required: true,
      },
      total_answer_eight: {
        required: true
      },
      total_answer_ten: {
        required: true
      }
    }

    // 验证字段的提示信息，若不传则调用默认的信息
    const messages = {
      city: {
        required: '请选择所在城市',
      },
      district: {
        required: '请选择行政区域',
      }
    }

    this.WxValidate = new WxValidate(rules, messages)
  },

  showModal(message) {
    wx.showModal({
      content: message.msg,
      showCancel: false,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;

    wx.request({
      url: constant.api(app.globalData.pord).url + '/satisfaction-survey/index?unionid=' + that.data.unionid,
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: function (res) {
        debugger
        if (res.data.code == "0") {
          that.setData({
            survey: res.data.data.survey,
            questionTwo: res.data.data.questionTwo
          });
        } else {
          wx.showToast({
            title: res.data.message,
            icon: 'none',
            duration: 1000
          })
        }
      },
      fail: function (res) {
        wx.showToast({
          title: '加载数据失败',
          icon: 'none',
          duration: 1000
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  }
})